package com.sqly.doc.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sqly.doc.R;

import java.util.List;

/**
 * Created by 袁从斌 on 2019-08-02.
 */
public class ControlAdapter extends BaseAdapter {
	private Context mContext;
	private List<String> mData;

	public ControlAdapter(Context context, List<String> data) {
		mContext = context;
		mData = data;
	}

	@Override
	public int getCount() {
		return mData.size();
	}

	@Override
	public Object getItem(int position) {
		return mData.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		PopHolder holder = null;
		if (convertView==null){
			holder = new PopHolder();
			convertView = LayoutInflater.from(mContext).inflate(R.layout.item_pop, parent, false);
			holder.mTv = (TextView) convertView.findViewById(R.id.tv);
			convertView.setTag(holder);
		}else {
			holder = (PopHolder) convertView.getTag();
		}
		holder.mTv.setText(mData.get(position));
		return convertView;
	}

}
